package com.xhsj.user.pms.workflow.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xhsj.user.pms.patent.domain.ExamineModel;
import com.xhsj.user.pms.patent.domain.TaskTransferModel;
import com.xhsj.user.pms.patent.domain.TransferModel;
import com.xhsj.user.pms.workflow.domain.WorkflowExec;
import com.xhsj.user.pms.workflow.model.WorkFlowScheduleModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Mapper
public interface WorkflowExecMapper extends BaseMapper<WorkflowExec> {

    /**
     * 根据专利ID删除对应进度集合
     * @param disclosureId
     * @return
     */
    int delExecProgressByDisclosureId(@Param("disclosureId") String disclosureId);
    //根据专利和当前的节点删除删除对应进度集合
    int delExecProgressByDisclosureIdAndNode(@Param("disclosureId") String disclosureId,
                                             @Param("nodeId") String nodeId);

    List<Map<String, Object>> selectNodeProgressListByUserId(@Param("disclosureId") String disclosureId,
                                                             @Param("userId") String userId,
                                                             @Param("roleIds") List<String> roleIds,
                                                             @Param("departmentIds") List<String> departmentIds);

    List<ExamineModel> findPatentAuditList(@Param("examineStatus") Integer examineStatus, @Param("userId") int userId, @Param("name") String name,
                                           @Param("inventor") String inventor, @Param("fullName") String fullName, @Param("deptName") String deptName,
                                           @Param("roleList") List<String> roleList, @Param("archivesNum") String archivesNum);


    // 审核完成
    IPage<ExamineModel> findPatentAuditListComplete(IPage<ExamineModel> page,@Param("examineStatus") Integer examineStatus, @Param("dealUser") String dealUser, @Param("name") String name,
                                                   @Param("roleList") List<String> roleList, @Param("archivesNum") String archivesNum,
                                                    @Param("param") Map<String, Object> param);

    IPage<ExamineModel> findPatentAuditListInComplete(IPage<ExamineModel> page,@Param("examineStatus") Integer examineStatus, @Param("userId") String userId, @Param("name") String name,
                                                     @Param("roleList") List<String> roleList, @Param("archivesNum") String archivesNum,
                                                      @Param("param") Map<String, Object> param);

    IPage<WorkFlowScheduleModel> getWorkFlowSchedule(IPage<WorkFlowScheduleModel> page, @Param("disclosureId") String disclosureId);

    //获取当前交底书所在的流程
    Long getWorkFlowExec(@Param("disclosureId") String disclosureId);

    //专利代办数
    Integer patentAgencyNum(@Param("userId") int userId, @Param("roleList") List<String> roleList);

    // 审核转入列表
    List<TransferModel> findPatentAuditTransferList(@Param("userId") String userId, @Param("roleList") List<String> roleList, @Param("taskType") String taskType);

    // 个人转入列表
    List<TransferModel> findPatentMyTransferList(@Param("userId") String userId, @Param("taskType") String taskType);

    //审批转出列表
    IPage<TransferModel> findPatentAuditTransferOutList(Page<TransferModel> page,@Param("userId") String userId, @Param("roleList") List<String> roleList, @Param("taskType") String taskType);

    // 个人转出列表
    IPage<TransferModel> findPatentMyTransferOutList(Page<TransferModel> page,@Param("userId") String userId, @Param("taskType") String taskType);

    //转让数据查询
    IPage<TaskTransferModel> findPatentTransferList(Page<TaskTransferModel> page,@Param("userId") String userId, @Param("taskType") String taskType);

    /**
     * 查询待审核列表数据
     * @author 苏小林
     * @date 2021/1/4 16:32
     * @param: page
     * @param: ids
     * @return: java.util.List<com.xhsj.user.pms.patent.domain.ExamineModel>
     */
    IPage<ExamineModel> findAuditList(IPage<Object> page, @Param("ids") Set<String> ids);

    /**
     * 查询审核历史数据
     * @author 苏小林
     * @date 2021/1/5 15:51
     * @param: page
     * @param: ids
     * @return: com.baomidou.mybatisplus.core.metadata.IPage<com.xhsj.user.pms.patent.domain.ExamineModel>
     */
    IPage<ExamineModel> findHiAuditList(IPage<Object> page, @Param("ids") Set<String> ids);

    /**
     * @Description: 专利统计-国内在审
     * @Param:  date 日期
     * @Author: liuqinghua
     * @Date: 2021/9/6
     */
    Integer getPatentStatistics(@Param("date") String date,@Param("isNow") boolean isNow);

//    流程专员冻结展示列表
    IPage<ExamineModel> findPatentAuditListAssistantName(IPage<ExamineModel> page,@Param("examineStatus") Integer examineStatus, @Param("name") String name,
                                          @Param("archivesNum") String archivesNum,
                                          @Param("param") Map<String, Object> param);
}